console.log("执行135")
if (UE) {
    UE.registerUI('135editor', function (editor, uiName) {
        // var dialog = new UE.ui.Dialog({
        //     iframeUrl: editor.options.UEDITOR_HOME_URL+'dialogs/135editor/135EditorDialogPage.html',
        //     cssRules:"width:"+ parseInt(document.body.clientWidth*0.9) +"px;height:"+(window.innerHeight -50)+"px;",
        //     editor:editor,
        //     name:uiName,
        //     title:"135缂栬緫鍣�"
        // });
        // dialog.fullscreen = false;
        // dialog.draggable = false;

        var editor135;
        function onContentFrom135(event) {
            if (typeof event.data !== 'string') {
                if (event.data.ready) {
                    editor135.postMessage(editor.getContent(), '*');
                }
                return;
            };

            if (event.data.indexOf('<') !== 0) return;

            editor.setContent(event.data);
            editor.fireEvent("catchRemoteImage");
            window.removeEventListener('message', onContentFrom135);
        }

        var btn = new UE.ui.Button({
            name: 'btn-dialog-' + uiName,
            className: 'edui-for-135editor',
            title: '135编辑器',
            onclick: function () {
                // dialog.render();
                // dialog.open();

                // 鐢变簬鍐呭祵iframe鐧诲綍瀛樺湪璺ㄥ煙闂锛岀鐢ㄤ簡cookie, 浣跨敤window.open鏂瑰紡璋冪敤135缂栬緫鍣�
                // 鑻ュ疄鐜拌处鍙锋墦閫氾紝鍏嶇櫥褰曟ā寮忥紝璇疯仈绯�135缂栬緫鍣ㄥ晢鍔�
                editor135 = window.open('https://www.135editor.com/beautify_editor.html?callback=true&appkey=', '135editor', 'height=' + (window.screen.availHeight - 100) + ',width=' + (window.screen.availWidth - 100) + ',top=50,left=50,help=no,resizable=no,status=no,scroll=no')

                window.removeEventListener('message', onContentFrom135);
                window.addEventListener('message', onContentFrom135, false);
            }
        });
        return btn;
    }, undefined);
} else {
    setInterval(() => {
        UE.registerUI('135editor', function (editor, uiName) {
            // var dialog = new UE.ui.Dialog({
            //     iframeUrl: editor.options.UEDITOR_HOME_URL+'dialogs/135editor/135EditorDialogPage.html',
            //     cssRules:"width:"+ parseInt(document.body.clientWidth*0.9) +"px;height:"+(window.innerHeight -50)+"px;",
            //     editor:editor,
            //     name:uiName,
            //     title:"135缂栬緫鍣�"
            // });
            // dialog.fullscreen = false;
            // dialog.draggable = false;

            var editor135;
            function onContentFrom135(event) {
                if (typeof event.data !== 'string') {
                    if (event.data.ready) {
                        editor135.postMessage(editor.getContent(), '*');
                    }
                    return;
                };

                if (event.data.indexOf('<') !== 0) return;

                editor.setContent(event.data);
                editor.fireEvent("catchRemoteImage");
                window.removeEventListener('message', onContentFrom135);
            }

            var btn = new UE.ui.Button({
                name: 'btn-dialog-' + uiName,
                className: 'edui-for-135editor',
                title: '135编辑器',
                onclick: function () {
                    // dialog.render();
                    // dialog.open();

                    // 鐢变簬鍐呭祵iframe鐧诲綍瀛樺湪璺ㄥ煙闂锛岀鐢ㄤ簡cookie, 浣跨敤window.open鏂瑰紡璋冪敤135缂栬緫鍣�
                    // 鑻ュ疄鐜拌处鍙锋墦閫氾紝鍏嶇櫥褰曟ā寮忥紝璇疯仈绯�135缂栬緫鍣ㄥ晢鍔�
                    editor135 = window.open('https://www.135editor.com/beautify_editor.html?callback=true&appkey=', '135editor', 'height=' + (window.screen.availHeight - 100) + ',width=' + (window.screen.availWidth - 100) + ',top=50,left=50,help=no,resizable=no,status=no,scroll=no')

                    window.removeEventListener('message', onContentFrom135);
                    window.addEventListener('message', onContentFrom135, false);
                }
            });
            return btn;
        }, undefined);
    }, 1000)
}
